#include "test_threadloop.h"
#include "mytest_log.h"

CThreadLoop::CThreadLoop()
{
}

CThreadLoop &CThreadLoop::Instance()
{
    static CThreadLoop tl;
    return tl;
}

void CThreadLoop::run()
{
    LOG_DEBUG("<>.<>.<> run() <>.<>.<>");
}

void CThreadLoop::do_check()
{
    pthread_t id;
    int ret = pthread_create(&id, NULL, loop_thread, NULL);
    if (ret != 0) {
        LOG_DEBUG("pthread_create failed !~");
    }
}

void * CThreadLoop::loop_thread(void *unused)
{
    sleep(3);
    LOG_DEBUG("jota loop_thread start !");
    while (true) {
        sleep(2);

        CThreadLoop::Instance().run();
    }

    LOG_DEBUG("jota loop_thread end ~!");
    return NULL;
}
